package org.team4.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.team4.constants.SQLConstant;
import org.team4.dao.DAOFactory;
import org.team4.dao.GenericDAO;
import org.team4.exception.CRUDException;

import org.team4.service.IService;


@Service
public class DeleteValidateService implements IService {

    private GenericDAO<Object> dao;

    @Autowired
    public void setSessionFactory(SessionFactory sessionFactory) {
        dao = (GenericDAO<Object>) DAOFactory.getDAO(sessionFactory, Object.class);
    }

    /**
     * 查找不能被删除的集合
     * 
     * @param idList
     * @param tableName
     * @return
     * @throws CRUDException
     */
    public List<List<String>> findCannotDeleteList(List<String> idList, String tableName) throws CRUDException {
        return dao.findCannotDeleteList(idList, SQLConstant.DELETE_TABLE_VALIDATE.get(tableName));
    }

}
